local sk__manwu = fk.CreateSkill {

  name = "sk__manwu",

  tags = {},

}



sk__manwu:addEffect("active", {
  name = "sk__manwu",
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__manwu",
  can_use = function(self, player)
    return player:usedSkillTimes(sk__manwu.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected, selected_cards)
    local target = to_select
    return #selected == 0 and to_select ~= player and not target:isKongcheng() and
        (target.gender == General.Male or target.gender == General.Bigender)
  end,
  on_use = function(self, room, effect)
    local player = reffect.from
    local target = effect.tos[1]
    local card = room:askForCardChosen(player, target, "h", sk__manwu.name, "#sk__manwu-choose::" .. target.id)
    local suit = Fk:getCardById(card).suit
    target:showCards(card)
    if not table.contains(target:getCardIds("h"), card) then return end
    if suit == Card.Diamond then
      if not target.dead and not table.contains(target.sealedSlots, Player.JudgeSlot) and
          not target:hasDelayedTrick("indulgence") then
        local c = Fk:cloneCard("indulgence")
        c:addSubcards({ card })
        c.skillName = sk__manwu.name
        target:addVirtualEquip(c)
        room:moveCardTo(c, Player.Judge, target, fk.ReasonJustMove, sk__manwu.name, nil, true, player)
      end
    elseif not player.dead then
      room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, sk__manwu.name, nil, true, player)
    end
  end,
})

return sk__manwu
